#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>

using namespace std;

void quick_sort(int arr[], int l, int r)
{
	if (l >= r)
		return;
	int m = l + r >> 1;
	int i = -1, j = r + 1;
	while(i < j)
	{
		do i++; while (arr[i] < arr[m]);
		do j--; while (arr[j] > arr[m]);
		if(i < j) swap(arr[i], arr[j]);
	} 
	
	quick_sort(arr, l, l);
	quick_sort(arr, l + 1, r);
}
int main()
{
	int arr[] = { 9 , 4, 13, 6, 0, 23, 89 , 57 };
	int n = sizeof(arr) / sizeof(int) - 1;
	cout << n << endl;
	quick_sort(arr, 0, n);
	for (int i = 0; i < n; i++)
	{
		cout << arr[i] << ' ';
	}
	return 0;
}